/*******************************************************************************************
 *  Repeat.c
 *
 *  Creating and managing Repeat object strucutres.
 *
 *******************************************************************************************/







/*******************************************************************************************
 *  INCLUDES :
 *******************************************************************************************/

/* System and library related : */
#include <stdlib.h>
#include <string.h>

/* Project related : */
#include "Repeat.h"







/*******************************************************************************************
 *  FUNCTIONS :
 *******************************************************************************************/

/*******************************************************************************************
 *  NEWREPEAT : Creates an empty Repeat object structure.
 *******************************************************************************************/
Repeat *newRepeat(void) {
	Repeat *r;

	/* Creating the container structure : */
	r = (Repeat *)malloc(sizeof(Repeat));


	/* Setting the object's type : */
	r->otype = repeat;


	/* Returning the still empty structure : */
	return r;

}




/*******************************************************************************************
 *  FREEREPEAT : destroys a Repeat object structure and all the objects it stores.
 *******************************************************************************************/
void freeRepeat(Repeat *r) {

	free(r->times);

	if(r->action != NULL)
		free(r->action);
	if(r->actionRef != NULL)
		free(r->actionRef);

	free(r);
}




/*******************************************************************************************
 *	SETREPEATTIMES	 	: srts the number of times the action will be repeated
 *  SETREPEATACTION		: assignes an action object to a Repeat object
 *  SETREPEATACTIONREF	: assignes an actionRef object to a Repeat object
 *******************************************************************************************/
void setRepeatTimes(Repeat *r, char *t) {
	r->times = t;
}

void setRepeatAction(Repeat *r, Action *a) {
	r->action = a;
}

void setRepeatActionRef(Repeat *r, ActionRef *ar) {
	r->actionRef = ar;
}
